package xiaodaow.xiaodao360.com.previewphoto.app;

import android.content.Context;
import android.util.DisplayMetrics;
import android.view.WindowManager;

/**
 * 屏幕工具类
 *
 * @author Administrator
 */
public class ScreenUtils {

    static ScreenUtils mScreenUtils;

    public static void init(Context context) {
        if (mScreenUtils == null) {
            synchronized (ScreenUtils.class) {
                if (mScreenUtils == null) {
                    mScreenUtils = new ScreenUtils(context);
                }
            }
        }
    }

    public static ScreenUtils getInstance() {
        return mScreenUtils;
    }

    private Context mContext;

    private int mScreenWidth;

    private int mScreenHeight;

    public ScreenUtils(Context context) {
        mContext = context;
        DisplayMetrics metrics = new DisplayMetrics();
        ((WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay().getMetrics(metrics);
        this.mScreenWidth = metrics.widthPixels;
        this.mScreenHeight = metrics.heightPixels;
    }

    public Context getContext() {
        return mContext;
    }

    public int getScreenWidth() {
        return mScreenWidth;
    }

    public int getScreenHeight() {
        return mScreenHeight;
    }

}
